$(function() {
	layui.use(['laypage', 'util', 'layer'], function() {
		var util = layui.util;
		var laypage = layui.laypage;
		var layer = layui.layer;
        var total;
		function find_opertionLog_list(page, rows) {
			var index;
			$.ajax({
				type: "get",
				url: "http://localhost:8080/ssmService/operationLog/selectPageOperationLog",
				async: false,
				data: {
					"queryParams.curr_page": page,
					"queryParams.page_size": rows
				},
				"beforeSend": function() {
					index = layer.load(3, {
						shade: [0.5, "black"]
					})
				},
				"success": function(result) {
					if(result.resultCode == 0) {
						layer.close(index);
						build_operationLog_list(result);
						
						total = result.data.total;
					} else {
						layer.msg("服务器错误，请联系管理员", {
							icon: 2,
							time: 1000
						});
					}
				},
				"error": function() {
					layer.msg("服务器错误，请联系管理员", {
						icon: 2,
						time: 1000
					});
				}
			});

		}

		function build_operationLog_list(result) {
			var operationLogList = result.data.list;
			$(".table_tbody").empty();
			$.each(operationLogList, function(index, item) {
				var tr = $("<tr></tr>");
				var td1 = $("<td></td>").text(item.user_account);
				var td2 = $("<td></td>").text(item.user_name);
				var td3 = $("<td></td>").text(item.request_ip);
				var td4 = $("<td></td>").text(util.toDateString(item.date, "yyyy-MM-dd HH:mm:ss"));
				var td5 = $("<td></td>").text(item.module);
				var td6 = $("<td></td>").text(item.type);
				var td7 = $("<td></td>").text(item.content);
				tr.append(td1).append(td2).append(td3).append(td4)
					.append(td5).append(td6).append(td7).appendTo(".table_tbody");

			});

		}
		find_opertionLog_list(1,10);
        laypage.render({
        	elem:"table_page",
        	count:total,
        	layout:['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'],
        	jump:function(obj,first){
        		if(!first){
        			find_opertionLog_list(obj.curr,obj.limit);
        		}
        	}
        	
        });
	});
})